#include "Problem.h"
#include "problem1.h"


//dynamiclly constructed object within other method is not going out of scope after method terminates
Problem * Problem::createProblem(int problemNumber)
{
     Problem * problem=NULL;
     switch (problemNumber) {
         case 1: {
              problem=new problem1();
              break;
         }
         default: {
              problem=new problem1();
              break;
         }
     }
     return problem;
}

Problem::Problem():
     minimum(true),
     bestOptimum(0.0),
     knownOptimum(false),
     dimention(0),
     numberOfProblems(0)
{
}
Problem::~Problem(){}

void Problem::setCoordinate(Coordinate coor)
{
     coordinates.push_back(coor);
}

void Problem::setCoordinate(double & lower, double & upper)
{
     Coordinate coor(lower, upper);
     coordinates.push_back(coor);
}
//void Problem::setDefaultCoordinates(bool isDefault, int dim) {
//  coordinates.resize(dim);
//}
void Problem::printProblem()const
{
     std::cout<< "dimention: "<<getDimention()<<"; is minimum: "<<getMinimum()<<"; is known global optimum: ";
     std::cout<< getKnownOptimum()<<"; bestKnownMin : "<<getBestKnownOptimum()<<std::endl;
}

void Problem::printCoordinates()const
{
     unsigned int i=0;
     for(i=0; i<coordinates.size(); i++)
          coordinates[i].printCoordinate();
}
